﻿using Microsoft.Extensions.DependencyInjection;
using Modules.CheckInCount.Repositories;
using Modules.CheckInCount.StatisticModels;
using PmSoft;

namespace Modules.CheckInCount;

/// <summary>
/// 考勤统计专用业务逻辑类
/// </summary>

[UseDI(ServiceLifetime.Scoped)]
public class CheckInStatisticService
{
    private readonly CheckInStatisticRepository checkInStatisticRepository;

    public CheckInStatisticService(CheckInStatisticRepository checkInStatisticRepository)
    {
        this.checkInStatisticRepository = checkInStatisticRepository;
    }

    /// <summary>
    /// 获取项目考勤统计
    /// </summary>
    /// <param name="stageType">计数阶段</param>
    /// <param name="projectId">项目ID</param>
    /// <param name="date">日期</param>
    /// <returns></returns>
    public ProjectCheckinStatisticInfo GetProjectCheckinStatisticInfo(CountStageType stageType, int projectId, DateTime date)
    {
        return checkInStatisticRepository.GetProjectCheckinStatisticInfo(stageType, projectId, date);
    }

    /// <summary>
    /// 获取项目指定月份考勤天数
    /// </summary>
    /// <param name="projectId"></param>
    /// <param name="year"></param>
    /// <param name="month"></param>
    /// <returns></returns>
    public int GetProjectCheckinDays(int projectId, int year, int month)
    {
        return checkInStatisticRepository.GetProjectCheckinDays(projectId, year, month);
    }
}
